package com.yjt.fresh.activity;

import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.bigkoo.pickerview.builder.OptionsPickerBuilder;
import com.bigkoo.pickerview.listener.OnOptionsSelectListener;
import com.bigkoo.pickerview.view.OptionsPickerView;
import com.bumptech.glide.DrawableTypeRequest;
import com.bumptech.glide.Glide;
import com.google.gson.Gson;
import com.lzy.imagepicker.ImagePicker;
import com.lzy.imagepicker.bean.ImageItem;
import com.lzy.imagepicker.ui.ImageGridActivity;
import com.wzgiceman.rxretrofitlibrary.retrofit_rx.Api.BaseResultEntity;
import com.wzgiceman.rxretrofitlibrary.retrofit_rx.http.HttpManager;
import com.wzgiceman.rxretrofitlibrary.retrofit_rx.listener.HttpOnNextListener;
import com.yjt.fresh.R;
import com.yjt.fresh.api.ApiAddStore;
import com.yjt.fresh.api.ApiGetOpenStoreInfo;
import com.yjt.fresh.api.ApiImageUpload;
import com.yjt.fresh.base.BaseSimpleActivity;
import com.yjt.fresh.bean.BeanOpenStore;
import com.yjt.fresh.bean.BeanUploadIMG;
import com.yjt.fresh.bean.JsonBean;
import com.yjt.fresh.constant.MyConstants;
import com.yjt.fresh.dialog.CustomViewBottomDialog;
import com.yjt.fresh.utils.GetJsonDataUtil;
import com.yjt.fresh.utils.PreferenceManager;
import com.yjt.fresh.widget.CustomToastResult;

import org.json.JSONArray;

import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import butterknife.BindView;
import butterknife.ButterKnife;
import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;

/**
 * 我要开店
 * Created by mcc on 2018/8/7.
 */

public class AtyOpenStore extends BaseSimpleActivity {
    @BindView(R.id.rlBack)
    RelativeLayout mRlBack;
    @BindView(R.id.tvAppAtyOpenStoreReview)
    TextView mTvReview;
    @BindView(R.id.etAppAtyOpenStoreName)
    EditText mEtStoreName;
    @BindView(R.id.rbAppAtyOpenStoreSelf)
    RadioButton mRbSelf;
    @BindView(R.id.rbAppAtyOpenStoreOther)
    RadioButton mRbOther;
    @BindView(R.id.tvAppAtyOpenStoreAddress)
    TextView mTvAddress;
    @BindView(R.id.arrow)
    ImageView mArrow;
    @BindView(R.id.etAppAtyOpenStoreAddressDetail)
    EditText mEtAddressDetail;
    @BindView(R.id.ivAppAtyOpenStoreBusinessPhoto)
    ImageView mIvBusinessPhoto;
    @BindView(R.id.ivAppAtyOpenStoreLicencePhoto)
    ImageView mIvLicencePhoto;
    @BindView(R.id.ivAppAtyOpenStoreIDCardFace)
    ImageView mIvIDCardFace;
    @BindView(R.id.ivAppAtyOpenStoreIDCardBack)
    ImageView mIvIDCardBack;
    @BindView(R.id.etAppAtyOpenStoreLegalName)
    EditText mEtLegalName;
    @BindView(R.id.etAppAtyOpenStoreIDCardNum)
    EditText mEtIDCardNum;
    @BindView(R.id.etAppAtyOpenStoreContact)
    EditText mEtContact;
    @BindView(R.id.etAppAtyOpenStoreContactPhone)
    EditText mEtContactPhone;
    @BindView(R.id.cbAppAtyOpenStoreAgree)
    CheckBox mCbAgree;
    @BindView(R.id.tvAppAtyOpenStoreArgument)
    TextView mTvArgument;
    @BindView(R.id.btnAppAtyOpenStoreSubmit)
    Button mBtnSubmit;
    @BindView(R.id.rgAppAtyOpenStore)
    RadioGroup mRgBusinessType;
    @BindView(R.id.rlAppAtyOpenStoreReview)
    RelativeLayout mRlReview;
    @BindView(R.id.tvAppAtyOpenStoreStoreType)
    TextView mTvStoreType;
    @BindView(R.id.rlAppAtyOpenStoreStoreType)
    RelativeLayout mRlStoreType;
    @BindView(R.id.tvAppAtyOpenStoreReason)
    TextView mTvReason;
    @BindView(R.id.llAppAtyOpenStoreReason)
    LinearLayout mLlReason;
    @BindView(R.id.llAppAtyOpenStoreStoreType)
    LinearLayout mLlStoreType;
    @BindView(R.id.ivAppAtyOpenStoreReview)
    ImageView mIvReview;
    private ArrayList<JsonBean> options1Items = new ArrayList<>();
    private ArrayList<ArrayList<String>> options2Items = new ArrayList<>();
    private ArrayList<ArrayList<ArrayList<String>>> options3Items = new ArrayList<>();
    private String mProvince;
    private String mCity;
    private String mArea;
    private CustomViewBottomDialog mBottomDialog;
    private int mClickImgID;
    private String mIvBusinessPhotoUrl;
    private String mIvLicencePhotoUrl;
    private String mIvIDCardFaceUrl;
    private String mIvIDCardBackUrl;
    private String mBusinessType = "健康肉经销商";
    private String mApplyStatus;

    @Override
    protected int getContentView() {
        return R.layout.app_aty_open_store;
    }

    @Override
    protected void initViews() {
        ButterKnife.bind(this);
    }

    @Override
    protected void initEvent() {
        initClick();
        initStatus();
    }

    private void initClick() {
        mRlBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        mTvArgument.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(mContext,AtyShopArgument.class);
                startActivity(intent);
            }
        });
        mRgBusinessType.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                if (checkedId == mRbSelf.getId()) {
                    mBusinessType = "健康肉经销商";
                } else if (checkedId == mRbOther.getId()) {
                    mBusinessType = "养殖材料经销商";
                }
            }
        });
        mBtnSubmit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (TextUtils.isEmpty(mEtStoreName.getText().toString())) {
                    Toast.makeText(mContext, "请输入店铺名", Toast.LENGTH_SHORT).show();
                    return;
                }

                if (mProvince == null && mCity == null && mArea == null) {
                    Toast.makeText(mContext, "请选择省市区", Toast.LENGTH_SHORT).show();
                    return;
                }

                if (TextUtils.isEmpty(mEtAddressDetail.getText().toString())) {
                    Toast.makeText(mContext, "请输入详细地址", Toast.LENGTH_SHORT).show();
                    return;
                }

                if (mIvBusinessPhotoUrl == null) {
                    Toast.makeText(mContext, "请选择营业执照", Toast.LENGTH_SHORT).show();
                    return;
                }

                if (mIvLicencePhotoUrl == null) {
                    Toast.makeText(mContext, "请选择开户许可证照", Toast.LENGTH_SHORT).show();
                    return;
                }

                if (mIvIDCardFaceUrl == null) {
                    Toast.makeText(mContext, "请选择身份证正面照", Toast.LENGTH_SHORT).show();
                    return;
                }

                if (mIvIDCardBackUrl == null) {
                    Toast.makeText(mContext, "请选择身份证反面照", Toast.LENGTH_SHORT).show();
                    return;
                }

                if (TextUtils.isEmpty(mEtLegalName.getText().toString())) {
                    Toast.makeText(mContext, "请输入法人姓名", Toast.LENGTH_SHORT).show();
                    return;
                }

                if (TextUtils.isEmpty(mEtContact.getText().toString())) {
                    Toast.makeText(mContext, "请输入联系人", Toast.LENGTH_SHORT).show();
                    return;
                }

                if (TextUtils.isEmpty(mEtContactPhone.getText().toString())) {
                    Toast.makeText(mContext, "请输入联系人电话", Toast.LENGTH_SHORT).show();
                    return;
                }
                if (TextUtils.isEmpty(mEtIDCardNum.getText().toString())) {
                    Toast.makeText(mContext, "请输入法人身份证号", Toast.LENGTH_SHORT).show();
                    return;
                }

                if (!mCbAgree.isChecked()){
                    Toast.makeText(mContext, "请先同意开店协议", Toast.LENGTH_SHORT).show();
                    return;
                }
                submit();

            }
        });

        mTvAddress.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                initAreaData();
            }
        });

        mIvBusinessPhoto.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mClickImgID = v.getId();
                if (mBottomDialog == null) {
                    mBottomDialog = new CustomViewBottomDialog(mContext);
                    initAlterPhotoDialogView();
                    mBottomDialog.builder();
                }
                mBottomDialog.show();
            }
        });

        mIvLicencePhoto.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mClickImgID = v.getId();
                if (mBottomDialog == null) {
                    mBottomDialog = new CustomViewBottomDialog(mContext);
                    initAlterPhotoDialogView();
                    mBottomDialog.builder();
                }
                mBottomDialog.show();
            }
        });

        mIvIDCardFace.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mClickImgID = v.getId();
                if (mBottomDialog == null) {
                    mBottomDialog = new CustomViewBottomDialog(mContext);
                    initAlterPhotoDialogView();
                    mBottomDialog.builder();
                }
                mBottomDialog.show();
            }
        });

        mIvIDCardBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mClickImgID = v.getId();
                if (mBottomDialog == null) {
                    mBottomDialog = new CustomViewBottomDialog(mContext);
                    initAlterPhotoDialogView();
                    mBottomDialog.builder();
                }
                mBottomDialog.show();
            }
        });
    }

    HttpOnNextListener<BaseResultEntity> mAddStoreListener = new HttpOnNextListener<BaseResultEntity>() {
        @Override
        public void onNext(BaseResultEntity baseResultEntity) {
            CustomToastResult.show("提交成功");
            finish();
        }

        @Override
        public void onReLogin() {
            toLogin();
        }
    };

    private void submit() {
        ApiAddStore apiAddStore = new ApiAddStore(mAddStoreListener, mContext, true, false, false);
        Map<String, Object> map = new HashMap<>();
        map.put("TRUE_NAME", mEtLegalName.getText().toString());
        map.put("PHONE", mEtContactPhone.getText().toString());
        map.put("STORE_NAME", mEtStoreName.getText().toString());
        map.put("PROVINCE", mProvince);
        map.put("CITY", mCity);
        map.put("AREA", mArea);
        map.put("ADDRESS", mEtAddressDetail.getText().toString());
        map.put("ONE_TYPE", mBusinessType);
        map.put("ACCOUNTLICENSE", mIvLicencePhotoUrl);
        map.put("BUSINESSLICENSE", mIvBusinessPhotoUrl);
        map.put("IDCARDPIC", mIvIDCardFaceUrl + "," + mIvIDCardBackUrl);
        map.put("IDNO", mEtIDCardNum.getText().toString());
        map.put("CONTECTMAN", mEtContact.getText().toString());
        map.put("SESSION_ID",PreferenceManager.getInstance().getUserInfo().getSESSION_ID());
        apiAddStore.setMap(map);
        HttpManager.getInstance().doHttpDeal(apiAddStore);
    }

    private void initStatus() {
        mApplyStatus = getIntent().getStringExtra(MyConstants.IS_APPLY);
        switch (mApplyStatus) {
            case "0"://未提交
                mRlReview.setVisibility(View.GONE);
                mBtnSubmit.setVisibility(View.VISIBLE);
                mRlStoreType.setVisibility(View.GONE);
                mLlStoreType.setVisibility(View.VISIBLE);
                mLlReason.setVisibility(View.GONE);
                break;
            case "1"://待审核
                mBtnSubmit.setVisibility(View.GONE);
                mRlReview.setVisibility(View.VISIBLE);
                mRlStoreType.setVisibility(View.VISIBLE);
                mLlStoreType.setVisibility(View.GONE);
                mRlReview.setBackgroundColor(getResources().getColor(R.color.color_43b624));
                mIvReview.setImageResource((R.mipmap.f8_ic_07));
                mCbAgree.setVisibility(View.GONE);
                mTvArgument.setVisibility(View.GONE);
                mTvReview.setText("等待审核");
                getData();
                break;
            case "2"://审核不通过
                mCbAgree.setVisibility(View.VISIBLE);
                mTvArgument.setVisibility(View.VISIBLE);
                mLlStoreType.setVisibility(View.VISIBLE);
                mRlReview.setVisibility(View.VISIBLE);
                mRlStoreType.setVisibility(View.GONE);
                mLlReason.setVisibility(View.VISIBLE);
                mRlReview.setBackgroundColor(getResources().getColor(R.color.color_ff9926));
                mIvReview.setImageResource((R.mipmap.f8_ic_08));
                mTvReview.setText("审核不通过");

                mBtnSubmit.setVisibility(View.VISIBLE);
                mBtnSubmit.setText("重新提交");
                getData();
                break;
            case "3"://审核通过
                mCbAgree.setVisibility(View.GONE);
                mTvArgument.setVisibility(View.GONE);
                mLlStoreType.setVisibility(View.GONE);
                mBtnSubmit.setVisibility(View.GONE);
                mRlReview.setVisibility(View.VISIBLE);
                mRlStoreType.setVisibility(View.VISIBLE);
                mRlReview.setBackgroundColor(getResources().getColor(R.color.color_43b624));
                mIvReview.setVisibility(View.GONE);
                mTvReview.setText("审核通过");
                getData();
                break;
        }
    }

    HttpOnNextListener<BeanOpenStore> mGetInfoListener = new HttpOnNextListener<BeanOpenStore>() {
        @Override
        public void onNext(BeanOpenStore beanOpenStore) {
            mEtStoreName.setText(beanOpenStore.getSTORE_NAME());
            mTvStoreType.setText(beanOpenStore.getONE_TYPE());
            mTvAddress.setText(beanOpenStore.getPROVINCE()+" "+beanOpenStore.getCITY()+" "+beanOpenStore.getAREA());
            mProvince = beanOpenStore.getPROVINCE();
            mCity = beanOpenStore.getCITY();
            mArea = beanOpenStore.getAREA();
            mEtAddressDetail.setText(beanOpenStore.getADDRESS());
            Glide.with(mContext).load(beanOpenStore.getBUSINESSLICENSE()).into(mIvBusinessPhoto);
            mIvBusinessPhotoUrl = beanOpenStore.getBUSINESSLICENSE();
            Glide.with(mContext).load(beanOpenStore.getACCOUNTLICENSE()).into(mIvLicencePhoto);
            mIvLicencePhotoUrl = beanOpenStore.getACCOUNTLICENSE();
            String idCardUrl = beanOpenStore.getIDCARDPIC();
            String[] idCardUrls = idCardUrl.split(",");
            Glide.with(mContext).load(idCardUrls[0]).into(mIvIDCardFace);
            mIvIDCardFaceUrl = idCardUrls[0];
            Glide.with(mContext).load(idCardUrls[1]).into(mIvIDCardBack);
            mIvIDCardBackUrl = idCardUrls[1];
            if ("健康肉经销商".equals(beanOpenStore.getONE_TYPE())){
                mRbSelf.setChecked(true);
                mRbOther.setChecked(false);
                mBusinessType = "健康肉经销商";
            }else {
                mRbSelf.setChecked(false);
                mRbOther.setChecked(true);
                mBusinessType = "养殖材料经销商";
            }

            mEtLegalName.setText(beanOpenStore.getTRUE_NAME());
            mEtIDCardNum.setText(beanOpenStore.getIDNO());
            mEtContact.setText(beanOpenStore.getCONTECTMAN());
            mEtContactPhone.setText(beanOpenStore.getPHONE());
            mTvReason.setText(beanOpenStore.getREVIEWINFO());
        }

        @Override
        public void onReLogin() {

        }
    };

    private void getData() {
        if (!"2".equals(mApplyStatus) ) {//审核不通过时可以重新编辑
            mEtStoreName.setFocusable(false);
            mEtAddressDetail.setFocusable(false);
            mEtLegalName.setFocusable(false);
            mEtIDCardNum.setFocusable(false);
            mEtContact.setFocusable(false);
            mEtContactPhone.setFocusable(false);

            mTvAddress.setClickable(false);
            mIvBusinessPhoto.setClickable(false);
            mIvLicencePhoto.setClickable(false);
            mIvIDCardFace.setClickable(false);
            mIvIDCardBack.setClickable(false);
        }

        ApiGetOpenStoreInfo apiGetOpenStoreInfo = new ApiGetOpenStoreInfo(mGetInfoListener, mContext, true, false, false);
        Map<String, Object> map = new HashMap<>();
        map.put("SESSION_ID", PreferenceManager.getInstance().getUserInfo().getSESSION_ID());
        apiGetOpenStoreInfo.setMap(map);
        HttpManager.getInstance().doHttpDeal(apiGetOpenStoreInfo);
    }


    private void showPickerView() {// 弹出选择器

        OptionsPickerView pvOptions = new OptionsPickerBuilder(this, new OnOptionsSelectListener() {
            @Override
            public void onOptionsSelect(int options1, int options2, int options3, View v) {
                //返回的分别是三个级别的选中位置
                String province = options1Items.get(options1).getPickerViewText();
                String city = options2Items.get(options1).get(options2);
                String area = options3Items.get(options1).get(options2).get(options3);
                mProvince = province;
                mCity = city;
                mArea = area;
                String tx = province +
                        " " + city +
                        " " + area;
                mTvAddress.setText(tx);
            }
        })

                .setTitleText("城市选择")
                .setDividerColor(Color.BLACK)
                .setTextColorCenter(Color.BLACK) //设置选中项文字颜色
                .setContentTextSize(20)
                .build();

        /*pvOptions.setPicker(options1Items);//一级选择器
        pvOptions.setPicker(options1Items, options2Items);//二级选择器*/
        pvOptions.setPicker(options1Items, options2Items, options3Items);//三级选择器
        pvOptions.show();
    }

    private void initAreaData() {//解析数据

        /**
         * 注意：assets 目录下的Json文件仅供参考，实际使用可自行替换文件
         * 关键逻辑在于循环体
         *
         * */
        String JsonData = new GetJsonDataUtil().getJson(this, "province.json");//获取assets目录下的json文件数据

        ArrayList<JsonBean> jsonBean = parseData(JsonData);//用Gson 转成实体

        /**
         * 添加省份数据
         *
         * 注意：如果是添加的JavaBean实体，则实体类需要实现 IPickerViewData 接口，
         * PickerView会通过getPickerViewText方法获取字符串显示出来。
         */
        options1Items = jsonBean;

        for (int i = 0; i < jsonBean.size(); i++) {//遍历省份
            ArrayList<String> CityList = new ArrayList<>();//该省的城市列表（第二级）
            ArrayList<ArrayList<String>> Province_AreaList = new ArrayList<>();//该省的所有地区列表（第三极）

            for (int c = 0; c < jsonBean.get(i).getCityList().size(); c++) {//遍历该省份的所有城市
                String CityName = jsonBean.get(i).getCityList().get(c).getName();
                CityList.add(CityName);//添加城市
                ArrayList<String> City_AreaList = new ArrayList<>();//该城市的所有地区列表

                //如果无地区数据，建议添加空字符串，防止数据为null 导致三个选项长度不匹配造成崩溃
                if (jsonBean.get(i).getCityList().get(c).getArea() == null
                        || jsonBean.get(i).getCityList().get(c).getArea().size() == 0) {
                    City_AreaList.add("");
                } else {
                    City_AreaList.addAll(jsonBean.get(i).getCityList().get(c).getArea());
                }
                Province_AreaList.add(City_AreaList);//添加该省所有地区数据
            }

            /**
             * 添加城市数据
             */
            options2Items.add(CityList);

            /**
             * 添加地区数据
             */
            options3Items.add(Province_AreaList);
        }

        showPickerView();

    }


    public ArrayList<JsonBean> parseData(String result) {//Gson 解析
        ArrayList<JsonBean> detail = new ArrayList<>();
        try {
            JSONArray data = new JSONArray(result);
            Gson gson = new Gson();
            for (int i = 0; i < data.length(); i++) {
                JsonBean entity = gson.fromJson(data.optJSONObject(i).toString(), JsonBean.class);
                detail.add(entity);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return detail;
    }


    private void initAlterPhotoDialogView() {
        View view = View.inflate(mContext, R.layout.app_dialog_alter_photo, null);
        TextView tvCamera = view.findViewById(R.id.tvAppDialogAlterPhotoCamera);
        TextView tvAlbum = view.findViewById(R.id.tvAppDialogAlterPhotoAlbum);
        TextView tvCancel = view.findViewById(R.id.tvAppDialogAlterPhotoCancel);
        mBottomDialog.setView(view);

        tvCamera.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(mContext, ImageGridActivity.class);
                intent.putExtra(ImageGridActivity.EXTRAS_TAKE_PICKERS, true); // 是否是直接打开相机
                startActivityForResult(intent, MyConstants.PICK_IMG);
                mBottomDialog.dismiss();
            }
        });

        tvAlbum.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(mContext, ImageGridActivity.class);
                startActivityForResult(intent, MyConstants.PICK_IMG);
                mBottomDialog.dismiss();
            }
        });

        tvCancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mBottomDialog != null) {
                    mBottomDialog.dismiss();
                }
            }
        });
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == MyConstants.PICK_IMG && resultCode == ImagePicker.RESULT_CODE_ITEMS && data != null) {
            ArrayList<ImageItem> images = (ArrayList<ImageItem>) data.getSerializableExtra(ImagePicker.EXTRA_RESULT_ITEMS);
            DrawableTypeRequest<String> load = Glide.with(mContext).load(images.get(0).path);
            if (mClickImgID == mIvBusinessPhoto.getId()) {
                load.into(mIvBusinessPhoto);
            } else if (mClickImgID == mIvLicencePhoto.getId()) {
                load.into(mIvLicencePhoto);
            } else if (mClickImgID == mIvIDCardFace.getId()) {
                load.into(mIvIDCardFace);
            } else if (mClickImgID == mIvIDCardBack.getId()) {
                load.into(mIvIDCardBack);
            }


            uploadImage(images.get(0).path);
        }

    }

    HttpOnNextListener simpleOnNextListener = new HttpOnNextListener<BeanUploadIMG>() {
        @Override
        public void onNext(BeanUploadIMG data) {

            mIvBusinessPhoto.setClickable(true);
            mIvLicencePhoto.setClickable(true);
            mIvIDCardFace.setClickable(true);
            mIvIDCardBack.setClickable(true);
            if (mClickImgID == mIvBusinessPhoto.getId()) {
                mIvBusinessPhotoUrl = data.getIMG_URL();
            } else if (mClickImgID == mIvLicencePhoto.getId()) {
                mIvLicencePhotoUrl = data.getIMG_URL();
            } else if (mClickImgID == mIvIDCardFace.getId()) {
                mIvIDCardFaceUrl = data.getIMG_URL();
            } else if (mClickImgID == mIvIDCardBack.getId()) {
                mIvIDCardBackUrl = data.getIMG_URL();
            }

        }

        @Override
        public void onReLogin() {
            toLogin();
        }
    };

    private void uploadImage(String path) {
        mIvBusinessPhoto.setClickable(false);
        mIvLicencePhoto.setClickable(false);
        mIvIDCardFace.setClickable(false);
        mIvIDCardBack.setClickable(false);
        File file = new File(path);
        RequestBody requestBody = RequestBody.create(MediaType.parse("image/jpeg"), file);
        MultipartBody.Part part1 = MultipartBody.Part.createFormData("IMG", file.getName(), requestBody);
        ApiImageUpload postEntity = new ApiImageUpload(simpleOnNextListener, mContext, true, false, false);
        postEntity.setPart(part1);
        HttpManager manager = HttpManager.getInstance();
        manager.doHttpDeal(postEntity);
    }
}
